// pages/buyCard/index.js
let App=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    cardData:null,
    advantageList: [
      {icon: "../../images/icon_03.png", name: "0元会员实体卡", num: 1},
      {icon: "../../images/icon_04.png", name: "月度优惠券", num: 1},
      {icon: "../../images/icon_05.png", name: "积分兑好礼", num: 1},
      {icon: "../../images/icon_06.png", name: "当月首单获双倍积分", num: 1},
      {icon: "../../images/icon_07.png", name: "生日专属优惠券", num: 1},
      {icon: "../../images/icon_08.png", name: "等级倍数积分", num: 1},
      {icon: "../../images/icon_09.png", name: "新品免费试", num: 1}
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData(options)
    this.getCardDetail (options.id)
  },
  getCardDetail(id){
    wx.showLoading({
      title: "数据加载中..",
      mask: true
    });
    return new Promise((resolve,reject)=>{
      App._get('Card/Api002',{id},res=>{
        let data=res.data
        let cardData={bgUrl:data.cardLogo}
        console.log(cardData)
        this.setData({
          cardInfo:res.data,
          cardData
        })
        wx.hideLoading()
        resolve()
      })
    })
  },
  toPay(){
    wx.navigateTo({
      url:'/pages/address/select_address?id='+this.data.id
    })
  }
})